<?
class form_decorator_basic{

	private $rows;
	private $method;
	private $enctype;
	private $name;	
	private $action;
	
	public function __construct($iName, $iMethod, $iEnctype, $iAction){
		
		$this -> rows = array();
		$this -> name = $iName;
		$this -> method = $iMethod;
		$this -> enctype = $iEnctype;
			$this -> action = $iAction; 
		
		
	}


	public function addRow(form_element $element, form_label $iLabel = NULL){
		
		$label = '';
		$required = '';
		if(isset($iLabel)){
		
			if($element -> required){
			
			$required = '<em>*</em>';
			$iLabel -> addText($required);
			
		}
			
			$label = $iLabel -> render();
		}
		
		
		
		
		$this -> rows[] = 	"<li> \n" .
								
								$label. " \n" .
								
								$element -> render() . " \n " .
								"								
							</li> \n";
							
								 
	
	}

	
	private function heading(){
		
		
		$output = "	
		<form method = 'post' action = '". $this -> action."' enctype = '" . $this -> enctype . "'> \n
		<ul class='form_container' id='".$this -> name."_container'>
		" ;
	
		return $output;	
	}
	
	private function footer(){
	
		$output = "</ul> </form>\n";
		
		return $output;
	} 
	
	
	public function render(){
	
		$output = $this -> heading();
		
		foreach($this -> rows as $row){
		
			$output .= $row;
		
		}
		
		$output .= $this -> footer();	
		return $output;
	}
	
	
}




?>